﻿Imports System
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.Workflow.ComponentModel

Namespace System.Workflow.ComponentModel.Design
    <ActivityDesignerTheme(GetType(FaultHandlersActivityDesignerTheme))> _
    Friend NotInheritable Class FaultHandlersActivityDesigner
        Inherits ActivityPreviewDesigner
        ' Methods
        Public Overrides Function CanInsertActivities(ByVal insertLocation As HitTestInfo, ByVal activitiesToInsert As ReadOnlyCollection([Of] Activity)) As Boolean
            Dim activity As Activity
            For Each activity In activitiesToInsert
                If Not TypeOf activity Is FaultHandlerActivity Then
                    Return False
                End If
            Next
            Return MyBase.CanInsertActivities(insertLocation, activitiesToInsert)
        End Function

        Protected Overrides Sub Initialize(ByVal activity As Activity)
            MyBase.Initialize(activity)
            Me.HelpText = DR.GetString("DropExceptionsHere", New Object(0  - 1) {})
            MyBase.ShowPreview = False
        End Sub


        ' Properties
        Public Overrides ReadOnly Property CanExpandCollapse As Boolean
            Get
                Return False
            End Get
        End Property

        Public Overrides ReadOnly Property FirstSelectableObject As Object
            Get
                If (Me.Expanded AndAlso Me.IsVisible) Then
                    If ((Not MyBase.PreviewedDesigner Is Nothing) OrElse (Me.ContainedDesigners.Count > 0)) Then
                        Return MyBase.FirstSelectableObject
                    End If
                    If (Me.ContainedDesigners.Count = 0) Then
                        Return New ConnectorHitTestInfo(Me, HitTestLocations.Designer, 0).SelectableObject
                    End If
                End If
                Return Nothing
            End Get
        End Property

        Public Overrides ReadOnly Property LastSelectableObject As Object
            Get
                If (Me.Expanded AndAlso Me.IsVisible) Then
                    If ((Not MyBase.PreviewedDesigner Is Nothing) OrElse (Me.ContainedDesigners.Count > 0)) Then
                        Return MyBase.LastSelectableObject
                    End If
                    If (Me.ContainedDesigners.Count = 0) Then
                        Return New ConnectorHitTestInfo(Me, HitTestLocations.Designer, (Me.GetConnectors.GetLength(0) - 1)).SelectableObject
                    End If
                End If
                Return Nothing
            End Get
        End Property

        Public Overrides ReadOnly Property Views As ReadOnlyCollection([Of] DesignerView)
            Get
                Dim list As New List([Of] DesignerView)
                Dim view As DesignerView
                For Each view In MyBase.Views
                    If (((view.ViewId <> 2) AndAlso (view.ViewId <> 3)) AndAlso (view.ViewId <> 4)) Then
                        list.Add(view)
                    End If
                Next
                Return New ReadOnlyCollection([Of] DesignerView)(list)
            End Get
        End Property

    End Class
End Namespace

